package com.airbnb.mvrx.sample.features.clickread.views;

import android.content.Context;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.PagerSnapHelper;
import android.support.v7.widget.SnapHelper;
import android.util.AttributeSet;

import com.airbnb.epoxy.Carousel;

public class PagerCarousel extends Carousel {

    private PagerSnapHelper mSnapHelper;

    public PagerCarousel(Context context) {
        super(context);
    }

    public PagerCarousel(Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
    }

    public PagerSnapHelper getSnapHelper() {
        return mSnapHelper;
    }

    @Nullable
    @Override
    protected SnapHelperFactory getSnapHelperFactory() {
        return new SnapHelperFactory() {
            @NonNull
            @Override
            public SnapHelper buildSnapHelper(Context context) {
                mSnapHelper = new PagerSnapHelper();
                return mSnapHelper;
            }
        };
    }

    @NonNull
    @Override
    protected LayoutManager createLayoutManager() {
        return new LinearLayoutManager(getContext(), LinearLayoutManager.HORIZONTAL, false);
    }

    @Override
    protected int getDefaultSpacingBetweenItemsDp() {
        return 0;
    }
}
